package com.zx.ecode.ui.activity;

import android.content.Intent;
import android.opengl.ETC1;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.zx.ecode.R;
import com.zzp.basepresenter.ui.activity.BaseActivity;
import com.zzp.basepresenter.util.LayoutUtil;
import com.zzp.basepresenter.util.TextUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

public class LoginActivity extends BaseActivity {
    @BindView(R.id.tv_login_by_psd)
    TextView tvLoginByPsd;
    @BindView(R.id.iv_logo)
    ImageView ivLogo;
    @BindView(R.id.et_phone_num)
    EditText etPhoneNum;
    @BindView(R.id.btn_get_auth_code)
    Button btnGetAuthCode;
    @BindView(R.id.et_auth_code)
    EditText etAuthCode;
    @BindView(R.id.btn_login)
    Button btnLogin;

    @Override
    public int getContentView() {
        return R.layout.activity_login;
    }

    @Override
    public boolean fitWindow() {
        return false;
    }

    @Override
    public boolean softWindowAdjustPan() {
        return false;
    }

    @Override
    public void init(Bundle savedInstanceState) {
        ButterKnife.bind(this);
        tvLoginByPsd.setLayoutParams(LayoutUtil.getInstance().getRelativeLayoutMarginParams(context, tvLoginByPsd));
        btnLogin.setOnClickListener(v -> {
            if (TextUtils.getInstance().isEmpty(etAuthCode.getText().toString().trim())) {
                return;
            }
            if (TextUtils.getInstance().isEmpty(etPhoneNum.getText().toString().trim())) {
                return;
            }
            if (isSimpleClick()) {
                Intent intent = new Intent();
                intent.setClass(this, MainActivity.class);
                if (etPhoneNum.getText().toString().trim().equals("1")) {
                    intent.putExtra("user", 1);
                }
                if (etPhoneNum.getText().toString().trim().equals("2")) {
                    intent.putExtra("user", 2);
                }
                if (etPhoneNum.getText().toString().trim().equals("3")) {
                    intent.putExtra("user", 3);
                }
                if (etPhoneNum.getText().toString().trim().equals("4")) {
                    intent.putExtra("user", 4);
                }
                if (etPhoneNum.getText().toString().trim().equals("5")) {
                    intent.putExtra("user", 5);
                }
                startActivity(intent);
                finish();
            }
        });
    }
}
